package com.mujin.keji.collectionsystem.module.message.viewmodel;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModel;
import android.util.Log;

import com.mujin.keji.collectionsystem.base.BaseDto;
import com.mujin.keji.collectionsystem.base.BaseVo;
import com.mujin.keji.collectionsystem.module.message.dto.MsgDto;
import com.mujin.keji.collectionsystem.module.message.repository.IMsgRepository;
import com.mujin.keji.collectionsystem.module.message.repository.MsgRepository;
import com.mujin.keji.collectionsystem.module.message.vo.MsgVo;
import com.mujin.keji.collectionsystem.utils.EmptyUtils;
import com.mujin.keji.collectionsystem.utils.ToastUtils;

import static android.content.ContentValues.TAG;

/**
 * 消息viewmodel
 *
 * @author weishixiong
 * @Time 2018-04-28
 */

public class MsgViewModel extends ViewModel {

    private static final int PAGESIZE = 20;
    private LiveData<BaseDto<MsgDto>> msgRefreshLiveData;
    private IMsgRepository msgRepository;

    public LiveData<BaseDto<MsgDto>> getMsgRefreshLiveData(int page) {
        getMsg(page);
        return msgRefreshLiveData;
    }

    /**
     * 查询消息列表
     */
    public void getMsg(int currentPage) {
        msgRepository = new MsgRepository();
        MsgVo msgVo = new MsgVo();
        msgVo.setCurrentPage(currentPage);
        msgVo.setPageSize(PAGESIZE);
        this.msgRefreshLiveData = msgRepository.queryMsg(msgVo);
    }



}
